﻿using System;
using System.Windows;
using System.Windows.Data;

namespace ObjectEditor.Converters
{
    public static class Null
    {
        public static readonly IValueConverter ToCollapsed = new NullToVisibilityConverter(Visibility.Collapsed, Visibility.Visible);
    }

    public class NullToVisibilityConverter : IValueConverter
    {
        readonly Visibility _true;
        readonly Visibility _false;
        public NullToVisibilityConverter(Visibility t, Visibility f)
        {
            _true = t;
            _false = f;
        }

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value == null ? _true : _false;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
